<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./vue.js"></script>
</head>

<body>
    <div id="app">
        <div>
            <h1>{{arr}}</h1>
            <button @click="changeArr">修改arr</button>
        </div>
        <h1>
            {{user}}
        </h1>
        <div>
            <button @click="changeObject">修改user</button>
        </div>
    </div>
    <script>
        var app = new Vue({
            el: '#app',
            data: {
                arr:[1,2,3],
                user:{a:1}
            },
            methods:{
                changeArr(){
                    //set 要修改的数组,修改的索引下标,修改的值
                    Vue.set(this.arr,1,999)
                },
                changeObject(){
                    // $set 要修改的数组,修改的属性,修改的值
                    this.$set(this.user,'b','张三')
                }
            }
        })
    </script>
</body>

</html>